package edu.lit.cn.controller;

import com.alibaba.fastjson.JSON;
import edu.lit.cn.service.InspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;

@CrossOrigin
@RestController
@RequestMapping("inspection")
public class InspectionController {
    @Autowired
    InspectionService inspectionService;
    @GetMapping("getAll") //获取巡检信息表所有内容
    public Object getAll() {
        ArrayList<HashMap<String, Object>> all = inspectionService.getAll();
        return JSON.toJSON(all);
    }
    @GetMapping("getAbnormal") //获取巡检表检测项目1的非无异音结果
    public Object getAbnormal() {
        ArrayList<HashMap<String, Object>> abnormal = inspectionService.getAbnormal();
        return JSON.toJSON(abnormal);
    }
    @GetMapping("getAllInspectionInformation") //获取指定巡检的所有元数据和巡检结果
    public Object getAllInspectionInformation(){
        ArrayList<HashMap<String, Object>> allInspectionInformation = inspectionService.getAllInspectionInformation(38988);
        return JSON.toJSON(allInspectionInformation);
    }
}
